/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Proyecto.Entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Luis
 */
@Entity
@Table(name = "receta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Receta.findAll", query = "SELECT r FROM Receta r"),
    @NamedQuery(name = "Receta.findByIdReceta", query = "SELECT r FROM Receta r WHERE r.idReceta = :idReceta"),
    @NamedQuery(name = "Receta.findByFechaEmision", query = "SELECT r FROM Receta r WHERE r.fechaEmision = :fechaEmision")})
public class Receta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idReceta")
    private Integer idReceta;
    @Column(name = "Fecha_Emision")
    @Temporal(TemporalType.DATE)
    private Date fechaEmision;
    @JoinColumn(name = "Consulta_idConsulta", referencedColumnName = "idConsulta")
    @ManyToOne(optional = false)
    private Consulta consultaidConsulta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "recetaidReceta")
    private Collection<Descripcionreceta> descripcionRecetaCollection;

    public Receta() {
    }

    public Receta(Integer idReceta) {
        this.idReceta = idReceta;
    }

    public Integer getIdReceta() {
        return idReceta;
    }

    public void setIdReceta(Integer idReceta) {
        this.idReceta = idReceta;
    }

    public Date getFechaEmision() {
        return fechaEmision;
    }

    public void setFechaEmision(Date fechaEmision) {
        this.fechaEmision = fechaEmision;
    }

    public Consulta getConsultaidConsulta() {
        return consultaidConsulta;
    }

    public void setConsultaidConsulta(Consulta consultaidConsulta) {
        this.consultaidConsulta = consultaidConsulta;
    }

    @XmlTransient
    public Collection<Descripcionreceta> getDescripcionRecetaCollection() {
        return descripcionRecetaCollection;
    }

    public void setDescripcionRecetaCollection(Collection<Descripcionreceta> descripcionRecetaCollection) {
        this.descripcionRecetaCollection = descripcionRecetaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idReceta != null ? idReceta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Receta)) {
            return false;
        }
        Receta other = (Receta) object;
        if ((this.idReceta == null && other.idReceta != null) || (this.idReceta != null && !this.idReceta.equals(other.idReceta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Proyecto.Entidades.Receta[ idReceta=" + idReceta + " ]";
    }
    
}
